package com.capsulode.excel.conversion;

import com.capsulode.excel.exception.CellTypeNotExpectException;
import com.capsulode.excel.exception.ConversionFailException;
import org.apache.poi.ss.usermodel.Cell;

/**
 * A type conversion. Used to convert cell(or null) to your `Class` T.
 */
public interface Reader<T> {
    /**
     * Convert this cell to your type.
     * Must throw `IllegalStateException` when type exceed to indicate `Excel` file template wrong.
     * @param cell current cell. May be `null`.
     * @return the value of your type. <strong>Return {@code null} means cell is empty, maybe should use default value.</strong>
     * @throws ConversionFailException if conversion fails.
     * @throws CellTypeNotExpectException the excel type of current cell is unsupported.
     */
    T convert(Cell cell) throws ConversionFailException, CellTypeNotExpectException;
}
